home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-3411 / dkbtrace / dkb.doc < prev    next >
Text File  |  1989-09-11  |  64KB  |  1,452 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.         DKBtrace Ray-Tracer, Amiga/IBM Version 2.0
  8.  
  9.         "It's free, and it's well worth the price!"
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.      This program was written by:
  18.  
  19.              David Buck
  20.              22C Sonnet Cres.
  21.              Nepean, Ontario
  22.              Canada, K2H 8W7
  23.  
  24.      It has been made freely distributable.  The author retains the copyright
  25.      to the program but authorizes free distribution by BBS'es, networks or
  26.      by magnetic media.  The distributer may choose to charge for the cost of
  27.      the disk but should not sell the software for profit.  Non-profit
  28.      organizations such as clubs may charge for the software so long as the
  29.      price is reasonable (less than $5.00 more than the cost of the disk) and
  30.      so long as the buyers are informed that the program is freely
  31.      distributable. 
  32.  
  33.      The images and data files generated by the raytracer are the property of
  34.      the user of the software and may be used for any purpose without
  35.      restriction.
  36.  
  37.      The author makes no guarantees or warantees with this program and claims
  38.      no responsibility for any damage or loss of time caused by this program.
  39.      Bug reports may be sent to the author but the author is under no
  40.      obligation to provide bug fixes, features, or any support for this
  41.      software.
  42.  
  43.      I would also like to place the following conditions on the use of this
  44.      program:
  45.  
  46.      1) that it should not be used as part of any commercial package without
  47.     my explicit written consent.
  48.  
  49.      2) if you make any neat and interesting pictures, please send them to
  50.     me.
  51.  
  52.      3) If you make any changes to the source code, please let me know.  I'd
  53.     like to see what you've done.
  54.  
  55.      4) This text file should accompany the program.
  56.  
  57.  
  58.  
  59.      I can be reached on the following BBS'es
  60.  
  61.      ATX       (613) 526-4141
  62.      OMX       (613) 731-3419
  63.      Mystic    (613) 731-0088 or (613) 731-6698
  64.      FidoNet   1:163/109.9
  65.      Bitnet    David_Buck@Carleton.CA
  66.  
  67.  
  68.  
  69.  
  70. Section 0.1 - Recent Update History:
  71.  
  72.      Version 1.2 First release
  73.      Version 2.0 Conversion to the IBM done by Aaron A. Collins
  74.          New textures, Specular and Phong highlighting added by
  75.          Aaron A. Collins
  76.          Triangle, Smooth Triangle, Sphere, Plane support added by
  77.          David Buck
  78.          RAW, IFF and GIF image mapping added by David Buck and Aaron
  79.          Collins
  80.          Transparency and Fog added by David Buck
  81.          GIF format file reader by Steve Bennett (used with permission)
  82.          New Noise and DNoise functions by Robert Skinner
  83.            (used with permission)
  84.  
  85.      Aaron Collins can be reached on the following BBS'es
  86.  
  87.      Lattice BBS           (708) 916-1200
  88.      The Information Exchange BBS  (708) 945-5575
  89.      Stillwaters BBS           (708) 403-2826
  90.  
  91.      AAC: As of July of 1990, there will be a Ray-Trace specific BBS in the
  92.      (708) Area Code (Chicago suburbia) for all you Traceaholics out there. 
  93.      The phone number of this new BBS is (708) 358-5611. I will be Co-Sysop
  94.      of that board.  There is also a new Ray-Trace and Computer-Generated
  95.      Art specific SIG on Compuserve, GO COMART.  And now, back to the DOCS...
  96.  
  97.      Version 2.0 includes ANSI-C function prototyping for ALL functions,
  98.      TARGA format output file capability, and a reversal of the order of
  99.      writing screen data from the original DKB/QRT "RAW" file format.  For
  100.      IBM's, it has a crude VGA 320x200 by 256 color display rendering
  101.      ability.  If the image requested is larger than 320x200, every other
  102.      pixel horizontally and vertically is dropped from the display to keep it
  103.      all on the screen.
  104.  
  105.      Version 2.0 compiles under Turbo-C 2.0 on the IBM P.C. and Lattice C
  106.      5.05 on the Amiga.  The only file which contains the ANSI extensions is
  107.      dkbproto.h, so for non-ANSI compilers, you only need to remove the
  108.      declaration of the parameters in the config.h file and the whole thing
  109.      should compile.  There are several example config.h files for Amiga,
  110.      IBM, and Unix.  The appropriate  one should be copied over CONFIG.H, and
  111.      the MAKEFILE should be edited for your particular system and compiler
  112.      configuration before compilation.
  113.  
  114.      Version 2.0 has a significant difference from prior releases:  Speed!
  115.      The new primitives of SPHERE, PLANE, TRIANGLE, etc. greatly speed up
  116.      tracing.  Another significant speed-up is that world X-Y-Z values beyond
  117.      10 Million or so are ignored, and ray tracing beyond that distance will
  118.      cease.  This produces 2 minor peculiarities:
  119.  
  120.      1)   A black stripe at the horizon point of Pre-2.0 scene description
  121.       .data files that have "ground" and "sky" planes defined.  The
  122.       planes were traced out to a much greater "infinity" so this effect
  123.       was unnoticeable, prior to version 2.0.
  124.      2)   Tiny black pixels in the texture, or "Surface Acne".
  125.  
  126.  
  127.      This is usually caused by rays being refracted or reflected such that
  128.      the ray does not happen to hit any object, and eventually becomes black
  129.      in color as it gets too far away and gets clipped.  This effect can be
  130.      minimized by enclosing the scene with distant "walls", "floors", or
  131.      placing "ocean floors" beneath water, etc.  So far, no scenes have
  132.      required placing such planes behind the camera, unless an "environment
  133.      map" of sorts is desired.  See SKYTEST.DAT for several examples of
  134.      spurious distant planes.  If your "acne" still doesn't go away, it may
  135.      be due to a large pixel sample area and it's accidentally picking a point
  136.      which is just inside the primitive being hit.  This is a more tricky
  137.      problem to solve, and anti-aliasing the image will definitely help if
  138.      this sort of thing occurs.
  139.  
  140.      For IBM's, the program PICLAB by the Stone Soup Group offers excellent
  141.      image post-processing features and has direct TARGA 16/24/32 file format
  142.      compatibility, and will serve to palette map and translate the TARGA
  143.      images into .GIF's, etc.  The commercial application AUTODESK ANIMATOR
  144.      offers a CONVERT utility that also does an excellent job of palette
  145.      mapping a TARGA to .GIF format.  COLORIX VGA PAINT also offers TARGA
  146.      format reading and conversion facilities.    Those of you  with real TARGA
  147.      boards can view the files directly in 16 million colors and are lucky
  148.      and should know it!
  149.  
  150.      The Stone Soup Group also produces FRACTINT, the best fractal/Mandelbrot
  151.      program available at ANY price (and it too is FREE!) for the PC.  I
  152.      (AAC) have borrowed their Public Domain .GIF file reading routines for
  153.      the Image Map texture.  Here is their Copyright Notice from the GIF
  154.      Decoder module:
  155.  
  156.       * DECODER.C - An LZW decoder for GIF
  157.       * Copyright (C) 1987, by Steven A. Bennett
  158.       *
  159.       * Permission is given by the author to freely redistribute and include
  160.       * this code in any program as long as this credit is given where due.
  161.       *
  162.       * In accordance with the above, I want to credit Steve Wilhite, who
  163.       * wrote the code which this is heavily inspired by...
  164.       *
  165.       * GIF and 'Graphics Interchange Format' are trademarks (tm) of
  166.       * Compuserve, Incorporated, an H&R Block Company.
  167.  
  168.  
  169.  
  170. Section 0.5 - Program Description:
  171.  
  172.  
  173.      This program is a ray tracer written completely in C.  It supports
  174.      arbitrary quadric surfaces (spheres, ellipsoids, cones, cylinders,
  175.      planes, etc.), constructive solid geometry, and various shading models
  176.      (reflection, refraction, marble, wood, and many others).  It also has
  177.      special-case code to handle spheres, planes, triangles, and smooth
  178.      triangles.  By using these special primitives, the rendering can be done
  179.      much more quickly than by using the more general quadrics. 
  180.      In order to create pictures with this program, you must describe the   
  181.      objects in the world.  This description is a text file called   
  182.      "<filename>.data", and <filename> defaults to "object" if not specified.
  183.      Normally, such files are difficult to write and to read.  In order to
  184.      make this task easier, the program contains a two-pass parser to read
  185.      the data file.  It allows the user to easily create complex worlds from
  186.      simple components.  Since the parser allows include files, the user may
  187.      put the object descriptions into different files and combine them all
  188.      into one final image.
  189.  
  190.      This manual is divided into four main sections.  The first section   
  191.      describes the command-line parameters for the program.  The second
  192.      section describes the syntax and semantics of the description language. 
  193.      Some sample worlds and their corresponding images are provided on the
  194.      disk.  The third section details how to display and convert the images
  195.      using various postprocesors, and section four has a collection of handy
  196.      hints for using the tracer most effectively as well as some quick start
  197.      procedures. 
  198.  
  199.  
  200. Section 1 - Command Line Parameters
  201.  
  202.      This program is designed to be run from the CLI, although it can be run
  203.      from the Workbench if desired.  From the CLI, the program accepts
  204.      various parameters:
  205.  
  206.      -wxxx     width of the picture in pixels
  207.            (On the Amiga, use 319 for full-sized pictures)
  208.      -hxxx     height of the picture in pixels
  209.            (On the Amiga, use 400 for full-sized pictures)
  210.  
  211.      +v        verbose option - print out the scan line number.
  212.      -v        disable verbose option
  213.  
  214.      +f        produce an output file
  215.      -f        don't produce an output file
  216.  
  217.            If the +f option is used, the ray tracer will produce an
  218.            output file of the picture.  This output file describes each
  219.            pixel with 24 bits (8 bits for red, 8 for green, and 8 for
  220.            blue). A post processor (Amiga only) called "DumpToIFF" can
  221.            convert this format to hi-res HAM format (320 x 400) making
  222.            reasonable choices for the colour registers.  For compati-
  223.            bility, the format of the dump file is the same as the format 
  224.            for the QRT ray tracer.    With Version 2.0, you can substitute
  225.            the "t" character for the "f" character and produce output
  226.            files directly in the Truevision (R) TARGA 24 format.  This
  227.            format is remarkably like the QRT/DKB raw format, so it was
  228.            easily done, and allows for a wider range of post-processing
  229.            programs to be used.  The extension .TGA is normally used for
  230.            such files, but any may be chosen.
  231.  
  232.      +d        display the picture while tracing
  233.      -d        don't display the picture while tracing
  234.  
  235.            If the +d option is used, then the picture will be displayed
  236.            while the program performs the ray tracing.  On the Amiga,
  237.            this picture is not as good as the one created by "DumpToIFF"
  238.            because it does not try to make optimum choices for the colour
  239.            registers.  Version 2.0 will produce a display on an IBM-PS/2
  240.            compatible VGA/MCGA display in 320x200 x 256 colours if the +d
  241.            option is given (Anyone for adding in SVGA resolutions??) but
  242.            the same basic caveat is still applicable: A good post-
  243.            processor will make better choices of the most popular colors
  244.            in the image to map to the display. 
  245.  
  246.      +p        wait for prompt (beep and pause) before quitting
  247.      -p        finish without waiting
  248.  
  249.            The +p option makes the program wait for a carriage return
  250.            before exiting (and closing the graphics screen).  This gives
  251.            you time to admire the final picture before destroying it. 
  252.  
  253.  
  254.   -ifilename   set the input filename
  255.   -ofilename   set output filename
  256.  
  257.            If your input file is not "Object.data", then you can use -i
  258.            to set the filename.  The default output filename will be
  259.            "data.display" on Amiga's, and either "data.dis" or "data.tga"
  260.            on IBM's, depending on the output file format that is being
  261.            used.  If you want a different output file name, use the -o
  262.            option.
  263.  
  264.      +a[xxx]   anti-alias - xxx is an optional tolerance level (default 0.3)
  265.      -a        don't anti-alias
  266.  
  267.            The +a option enables adaptive anti-aliasing.  The number
  268.            after the +a option determines the threshold for the anti-
  269.            aliasing.  If the colour of a pixel differs from its neighbor
  270.            (to the left or above) by more than the threshold, then the
  271.            pixel is subdivided and super-sampled.  The samples are
  272.            jittered to introduce noise and make the pictures look better. 
  273.            If the anti-aliasing threshold is 0.0, then every pixel is
  274.            supersampled.  If the threshold is 1.0, then no anti-aliasing
  275.            is done.  Good values seem to be around 0.2 to 0.4. 
  276.  
  277.      +x        allow early exit by hitting any key (IBM only)
  278.      -x        lock in trace until finished       (IBM only)
  279.  
  280.            On the IBM, the -e option disables the ability to abort the
  281.            trace by hitting a key.    If you are unusually clumsy or have
  282.            CATS that stomp on your keyboard (like I do - AAC :-)), you
  283.            may want to use it.  If you are writing a file, the system
  284.            will recognize ^C at the end of line if BREAK is on (on the
  285.            IBM).  If you aren't writing a file, you won't be able to
  286.            abort the trace until it's done.
  287.  
  288.            This option was meant for big, long late-nite traces that take
  289.            ALL night (or longer!), and you don't want them interrupted by
  290.            anything less important than a natural disaster such as hur-
  291.            ricane, fire, flood, famine, etc.
  292.  
  293.      -bxxx     use an output file buffer of xxx kilobytes.
  294.            (if 0, flush the file on every line - this is the default)
  295.  
  296.            The -b option allows you to assign large buffers to the output
  297.            file.  This reduces the amount of time spent writing to the
  298.            disk and prevents unnecessary wear (especially for floppies). 
  299.            If this parameter is zero, then as each scanline is finished,
  300.            the line is written to the file and the file is flushed.  On
  301.            most systems, this operation insures that the file is written
  302.            to the disk so that in the event of a system crash or other
  303.            catastrophic event, at least part of the picture has been
  304.            stored properly on disk.
  305.  
  306.  
  307.      -sxxx     start tracing at line number xxx.
  308.      -exxx     end tracing at line number xxx.
  309.  
  310.            The -s option is provided for when some natural or unnatural
  311.            catastrophe has occurred, and you want to restart the trace at
  312.            a given line number after the crash.  One is subtracted from
  313.            the given line number if anti-aliasing is activated (the prior
  314.            line's being computed is required for the anti-aliasing mech-
  315.            anism to function properly).  It can also be used to re-render
  316.            parts of an image (perhaps with anti-aliasing turned on).  A
  317.            separate utility can then merge the new lines into the old
  318.            file.  The particularly faint of heart or weak of power supply
  319.            may want to batch the image in "strips" of 10-20 lines and
  320.            concatenate them later.
  321.  
  322.      -qx       rendering quality
  323.  
  324.            The -q option allows you to specify the image rendering
  325.            quality.  The parameter can range from 0 to 9.  The values
  326.            correspond to the following quality levels:
  327.  
  328.            0,1  Just show colours.    Ambient lighting only.
  329.            2,3  Show Diffuse and Ambient light
  330.            4,5  Render shadows
  331.            6,7  Create surface textures
  332.            8,9  Compute reflected, refracted, and transmitted rays.
  333.  
  334.            The default is -q9 (maximum quality) if not specified.
  335.  
  336.            You may specify the default parameters by modifying the file
  337.            "trace.def" which contains the parameters in the above format. 
  338.            This filename contains a complete command line as though you 
  339.            had typed it in, and is processed before any options supplied
  340.            on the command line are recognized.
  341.  
  342.  
  343.  
  344.  
  345. Section 2 - The Object Description Language
  346.  
  347.      The Object Description Language allows the user to describe the world in
  348.      a readable and convenient way.
  349.  
  350.      The language delimits comments by the left and right braces ({ and }). 
  351.      Nested comments are allowed, but no sane person uses them anyway, right?
  352.      
  353.      The language allows include files to be specified by placing the line:
  354.  
  355.      INCLUDE "filename"
  356.  
  357.      at any point in the input file (Include files may be nested).
  358.  
  359.  
  360. Section 2.1 - The Basic Data Types
  361.  
  362.      There are several basic types of data:
  363.  
  364.   Float
  365.      Floats are represented by an optional sign (+ or -), some digits, an   
  366.      optional decimal point, and more digits.  It does not support the "e"  
  367.      notation for exponents.  The following are valid floats:
  368.  
  369.      1.0  -2.0    -4  +34
  370.  
  371.   Vector
  372.      Vectors are arrays of three floats.  They are bracketed by angle
  373.      brackets ( < and > ), and the three terms usually represent x, y, and z.
  374.      For example:
  375.  
  376.      < 1.0  3.2  -5.4578 >
  377.  
  378.   Colour
  379.      A colour consists of a red component, a green component, a blue
  380.      component, and possibly an alpha component.  All four components are
  381.      floats in the range 0.0 to 1.0.  The syntax for Colours is the word
  382.      "COLOUR" followed by any or all of the RED, GREEN, BLUE or ALPHA
  383.      components in any order.
  384.  
  385.      For example:
  386.  
  387.      COLOUR  RED 1.0  GREEN 1.0  BLUE 1.0
  388.      COLOUR  BLUE 0.56
  389.      COLOUR  GREEN 0.45 RED 0.3 ALPHA 0.3
  390.  
  391.      Alpha is a transparency indicator.  If an object's colour contains some 
  392.      transparency, then you can see through it.  If Alpha is 0.0, the object 
  393.      is totally opaque.  If it is 1.0, it is totally transparent.
  394.  
  395.      For those people who spell "Colour" the American way as "Color", the   
  396.      program also accepts "COLOR" as equivalent to "COLOUR" in all instances.
  397.  
  398.   COLOUR_MAP
  399.      For wood, marble, spotted, agate, granite, and gradient texturing, the
  400.      user may specify arbitrary colours to use for the texture.  This is done
  401.      by a colour map or "colour spline".  When the object is being textured,
  402.      a number between 0.0 and 1.0 is generated which is then used to form the
  403.      colour of the point.  A Colour map specifies the mapping used to change
  404.      these numbers into colours.  The syntax is as follows:
  405.  
  406.      COLOUR_MAP
  407.       [start_value end_value colour1 colour2]
  408.       [start_value end_value colour1 colour2]
  409.       ...
  410.      END_COLOUR_MAP
  411.  
  412.      The value is located in the colour map and the final colour is
  413.      calculated by a linear interpolation between the two colours in the
  414.      located range.
  415.  
  416. Section 2.2 - The More Complex Data Types
  417.  
  418.      The data types used to describe the objects in the world are a bit more 
  419.      difficult to describe.  To make this task easier, the program allows
  420.      users to describe these types in two ways.  The first way is to define
  421.      it from first principles specifying all of the required parameters.  The
  422.      second way allows the user to define an object as a modification of
  423.      another object (the other object is usually defined from first
  424.      principles but is much simpler).  Here's how it works:
  425.  
  426.      You can use the term DECLARE to declare a type of object with a certain 
  427.      description.  The object is not included in the world but it can be used
  428.      as a "prototype" for defining other objects, as this basic example
  429.      shows:
  430.  
  431.      DECLARE Sphere = QUADRIC
  432.       <1.0 1.0 1.0>
  433.       <0.0 0.0 0.0>
  434.       <0.0 0.0 0.0>
  435.       -1.0
  436.      END_QUADRIC
  437.  
  438.      To then reference the declaration elsewhere in your source file or in
  439.      another included one, and to actually include the object in the world,
  440.      you would define the object using object definition syntax, like this:
  441.  
  442.      OBJECT
  443.       QUADRIC Sphere
  444.            SCALE <20.0 20.0 20.0>
  445.       END_QUADRIC
  446.       COLOUR White
  447.       AMBIENT 0.2
  448.       DIFFUSE 0.8
  449.      END_OBJECT
  450.      The real power of declaration becomes apparent when you declare several
  451.      primitive types of objects and then define an object with several
  452.      component shapes, using either COMPOSITE methods or the CSG methods
  453.      INTERSECTION, UNION, or DIFFERENCE.  More on those later.    Also, using
  454.      the DECLARE keyword can make several objects share a texture without the
  455.      need for each object to store a duplicate copy of the same texture, for
  456.      more efficient memory usage.   Example:
  457.  
  458.      OBJECT        { A Hot dog in a Hamburger Bun (?) }
  459.       UNION
  460.            QUADRIC Sphere
  461.             SCALE <20.0, 10.0, 20.0>
  462.            END_QUADRIC
  463.            QUADRIC Cylinder_X
  464.             SCALE <40.0, 20.0, 20.0>
  465.            END_QUADRIC
  466.       END_UNION
  467.      END_OBJECT
  468.  
  469.  
  470.   Viewpoint
  471.      The viewpoint tells the ray tracer the location and orientation of the 
  472.      camera.  The viewpoint is described by four vectors - Location,
  473.      Direction, Up, and Right.    Location determines where the camera is
  474.      located.  Direction  determines the direction that the camera is
  475.      pointed.  Up determines the "up" direction of the camera.  Right
  476.      determines the direction to the right of the camera.
  477.  
  478.      A first principle's declaration of a viewpoint would look like this:   
  479.      
  480.      VIEWPOINT
  481.       LOCATION < 0.0  0.0  0.0>
  482.       DIRECTION < 0.0  0.0    1.0>
  483.       UP < 0.0  1.0  0.0 >
  484.       RIGHT < 1.0  0.0  0.0>
  485.      END_VIEWPOINT
  486.  
  487.      This format becomes cumbersome, however, because the vectors must be   
  488.      calculated by hand.  This is especially difficult when the vectors are
  489.      not lined up with the X, Y, and Z axes as they are in the above example. 
  490.      To make it easier to define the viewpoint, you can define one viewpoint,
  491.      then modify the description.  For example,
  492.  
  493.      VIEWPOINT
  494.       LOCATION < 0.0  0.0  0.0>
  495.       DIRECTION < 0.0  0.0    1.0>
  496.       UP < 0.0  1.0  0.0 >
  497.       RIGHT < 1.0  0.0  0.0 >
  498.       TRANSLATE < 5.0  3.0    4.0 >
  499.       ROTATE < 30.0  60.0  30.0 >
  500.      END_VIEWPOINT
  501.  
  502.      In this example, the viewpoint is created, then translated to another
  503.      point in space and rotated by 30 degrees about the X axis, 60 degrees
  504.      about the Y axis, and 30 degrees about the Z axis.
  505.  
  506.      Unfortunately, even this is somewhat cumbersome.  So, in version 2.0,
  507.      you can now specify two more parameters:
  508.  
  509.       SKY <vector>
  510.       LOOK_AT <vector>
  511.  
  512.      The SKY keyword tells the viewpoint where the sky is.  It tries to keep 
  513.      the camera's UP direction aligned as closely as possible to the sky. 
  514.      The LOOK_AT keyword tells the camera to look at a specific point.    The
  515.      camera is rotated as required to point directly at that point.  By
  516.      changing the  SKY vector, you can twist the camera while still looking
  517.      at the same point.
  518.  
  519.      Note that a pinhole camera model is used, so no focus or depth-of-field 
  520.      effects are supported at this time.
  521.    
  522.  
  523.      Version 2.0 of the raytracer includes the ability to render fog.  To add 
  524.      fog to a scene, place the following declaration outside of any object  
  525.      definitions:
  526.  
  527.      FOG
  528.       COLOUR  ... the fog colour
  529.       200.0   ... the fog distance
  530.      END_FOG
  531.  
  532.   Shapes
  533.      Shapes describe the shape of an object without mentioning any surface  
  534.      characteristics like colour, lighting and reflectivity.  The most
  535.      general shape used by this system is called a Quadric Surface.  Quadric
  536.      Surfaces can produce shapes like spheres, cones, and cylinders.  The
  537.      easiest way to define these shapes is to include the standard file
  538.      "BasicShapes.data" into your program and to transform these shapes
  539.      (using TRANSLATE, ROTATE, and SCALE) into the ones you want.  To be
  540.      complete, however, I will describe the mathematical principles behind
  541.      quadric surfaces.    Those who are not interested in the mathematical
  542.      details can skip to the next section.
  543.  
  544.      A quadric surface is a surface in three dimensions which satisfies the 
  545.      following equation:
  546.  
  547.  
  548.      A y**2  + B y**2  + C z**2
  549.      + D xy    + E xz     + F yz
  550.      + G x     + H y     + I z      + J = 0
  551.  
  552.  
  553.      (Did you really want to know that?  I didn't think so. :-)  DKB)
  554.  
  555.      Different values of A,B,C,...J will give different shapes.  So, if you
  556.      take any three dimensional point and use its x, y, and z coordinates in
  557.      the above equation, the answer will be 0 if the point is on the surface
  558.      of the object.  The answer will be negative if the point is inside the
  559.      object and positive if the point is outside the object.  Here are some
  560.      examples:
  561.  
  562.      X**2 + Y**2 + Z**2 - 1 = 0     Sphere
  563.      X**2 + Y**2 - 1 = 0        Cylinder along the Z axis
  564.      X**2 + Y**2 + Z = 0        Cone along the Z axis
  565.  
  566.      General quadric surfaces can be defined as follows:
  567.  
  568.      QUADRIC
  569.       < A B C >
  570.       < D E F >
  571.       < G H I >
  572.       J
  573.      END_QUADRIC
  574.  
  575.  
  576. Section 2.3 - Quadric surfaces the easy way
  577.  
  578.      Now that doesn't sound so hard, does it?  Well, actually, it does.  Only 
  579.      the hard-core graphics fanatic would define his objects using the
  580.      QUADRIC definition directly.  Even I don't do it that way and I know how
  581.      it works (Well, at least I worked it out once or twice :-) - DKB).
  582.  
  583.      Fortunately, there is an easier way. The file "BasicShapes.data" already
  584.      includes the definitions of many quadric surfaces.  They are centered
  585.      about the origin (0,0,0) and have a radius of 1.  To use them, you can
  586.      define shapes as follows:
  587.  
  588.  
  589.      INCLUDE "BasicShapes.data"
  590.  
  591.      QUADRIC
  592.       Cylinder_X
  593.       SCALE < 50.0    50.0  50.0 >
  594.       ROTATE < 30.0  10.0  45.0 >
  595.       TRANSLATE < 2.0  5.0    6.0 >
  596.      END_QUADRIC
  597.  
  598.  
  599.      You may have as many transformation lines (scale, rotate, and translate)
  600.      as you like in any order.    Usually, however, it's easiest to do a scale
  601.      first, one or more rotations, then finally a translation.    Otherwise,
  602.      the results may not be what you expect. (The transformations always
  603.      transform the object about the origin.  If you have a sphere at the
  604.      origin and you translate it then rotate it, the rotation will spin the
  605.      sphere around the origin like planets about the sun).
  606.  
  607.  
  608.  
  609. Section  2.4 - Spheres
  610.  
  611.      Since spheres are so common in ray traced graphics, A SPHERE primitive
  612.      has been added to the system.  This primitive will render much more
  613.      quickly than the corresponding quadric shape.  The syntax is:
  614.       
  615.      SPHERE  <center> radius END_SPHERE
  616.  
  617.      You can also add translations, rotations, and scaling to the sphere. 
  618.      For example, the following two objects are identical:
  619.  
  620.      OBJECT
  621.       SPHERE  < 0.0 25.0 0.0 > 10.0 END_SPHERE
  622.       COLOR Blue
  623.       AMBIENT 0.3
  624.       DIFFUSE 0.7
  625.      END_OBJECT
  626.  
  627.      OBJECT
  628.       SPHERE  < 0.0 0.0 0.0 > 1.0
  629.            TRANSLATE <0.0  25.0  0.0> 
  630.            SCALE <10.0  10.0  10.0>
  631.       END_SPHERE
  632.       COLOR Blue
  633.       AMBIENT 0.3
  634.       DIFFUSE 0.7
  635.      END_OBJECT
  636.  
  637.      Note that Spheres may only be scaled uniformly. You cannot use:
  638.  
  639.      SCALE <10.0 5.0 2.0>
  640.  
  641.      on a sphere.  If you need oblate spheroids such as this, use a scaled
  642.      quadric "Sphere" shape instead.
  643.  
  644. Section  2.5 - Planes
  645.  
  646.      Another primitive provided to speed up the raytracing is the PLANE. 
  647.      This is a flat infinite plane.  To declare a PLANE, you specify the
  648.      direction of the surface normal to the plane (the UP direction) and the
  649.      distance from the origin of the plane to the world's origin.  As with
  650.      spheres, you can translate, rotate, and scale planes.  Examples:
  651.  
  652.      PLANE <0.0  1.0  0.0> -10.0 END_PLANE   { A plane in the X-Z axes 10
  653.                          units below the world origin. }
  654.  
  655.      PLANE <0.0  1.0  0.0>  10.0 END_PLANE   { A plane in the X-Z axes 10
  656.                          units above the world origin. }
  657.  
  658.      PLANE <0.0  0.0  1.0>  -10.0 END_PLANE  { A plane in the X-Y axes 10
  659.                          units behind the world origin.}
  660.  
  661.  
  662. Section  2.6 - Triangles
  663.  
  664.      In order to make more complex objects than the class of quadrics will
  665.      permit, a new primitive shape for triangles has been added.  There are
  666.      two different types of triangles:    flat shaded triangles and smooth
  667.      shaded (Phong) triangles.
  668.  
  669.      Flat shaded triangles are defined by listing the three vertices of the 
  670.      triangle.    For example:
  671.    
  672.      TRIANGLE  < 0.0   20.0  0.0>
  673.            < 20.0  0.0   0.0>
  674.            <-20.0  0.0   0.0>
  675.      END_TRIANGLE
  676.  
  677.      The smooth shaded triangles use Phong Normal Interpolation to calculate
  678.      the surface normal for the triangle.  This makes the triangle appear to
  679.      be a smooth curved surface.  In order to define a smooth triangle,
  680.      however, you must supply not only the vertices, but also the surface
  681.      normals at those vertices.  For example:
  682.    
  683.      SMOOTH_TRIANGLE
  684.       {     points         surface normals    }
  685.       <  0.0  30.0    0.0 >     <0.0    0.7071     -0.7071>
  686.       < 40.0 -20.0    0.0 >     <0.0    -0.8664  -0.5    >
  687.       <-50.0 -30.0    0.0 >     <0.0    -0.5     -0.8664>
  688.      END_SMOOTH_TRIANGLE
  689.  
  690.      As with the other shapes, triangles can be translated, rotated, and
  691.      scaled.
  692.  
  693.      NOTE:  Triangles cannot be used in CSG INTERSECTION or DIFFERENCE types
  694.      (described next) since triangles have no clear "inside".  The CSG UNION
  695.      type works acceptably but with no difference from a COMPOSITE object.
  696.  
  697.  
  698. Section 2.7 - Constructive Solid Geometry (CSG)
  699.  
  700.      This ray tracer supports Constructive Solid Geometry in order to make
  701.      the object definition abilities more powerful.  Constructive Solid
  702.      Geometry allows you to define shapes which are the union, intersection,
  703.      or difference of other shapes.  Unions superimpose the two shapes.  This
  704.      has the same effect as defining two separate objects, but is simpler to
  705.      create and/or manipulate.    Intersections define the space where the two
  706.      surfaces meet.  Differences allow you to cut one object out of another.
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.      CSG Intersections, Unions, and Differences can consist of two or more
  716.      shapes.  They are defined as follows:
  717.  
  718.      OBJECT
  719.       INTERSECTION
  720.            QUADRIC
  721.             ...
  722.            END_QUADRIC
  723.  
  724.            QUADRIC
  725.             ...
  726.            END_QUADRIC
  727.  
  728.            QUADRIC
  729.             ...
  730.            END_QUADRIC
  731.       END_INTERSECTION
  732.       ...
  733.      END_OBJECT
  734.  
  735.      UNION or DIFFERENCE may be used instead of INTERSECTION.  The order of
  736.      the shapes doesn't matter except for the DIFFERENCE shapes.  For CSG
  737.      differences, the first shape is visible and the remaining shapes are cut
  738.      out of the first (in reverse order from version 1.2 DIFFERENCE's).
  739.  
  740.      Constructive solid geometry shapes may be translated, rotated, or scaled
  741.      in the same way as a Quadric surface.  The quadric surfaces making up
  742.      the CSG object may be individually translated, rotated, and scaled as
  743.      well.
  744.  
  745.      When using CSG, it is often useful to invert an shape so that it's
  746.      inside-out.  The INVERSE keyword can be used to do this for any SPHERE,
  747.      PLANE, or QUADRIC.  When INVERSE is used, the "inside" of the object is
  748.      flipped to be the "outside".  For Planes, "inside" is defined to be "in
  749.      the opposite direction to the "normal" or "up" direction.
  750.  
  751.      Note that performing an INTERSECTION between an shape and some other
  752.      INVERSE shapes is the same as performing a DIFFERENCE.  In fact, the
  753.      DIFFERENCE is actually implemented in this way.
  754.  
  755. Section  2.8 - Objects
  756.  
  757.      There is more to defining an object than just its shape.  You must tell
  758.      the ray tracer about the properties of the surface like colour, alpha,
  759.      reflectivity, refractivity, the index of refraction, and so on. To do
  760.      this, you must define Objects.
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.      A typical object definition looks something like this:
  769.  
  770.      OBJECT
  771.       QUADRIC Sphere
  772.            TRANSLATE < 40.0 40.0 60.0 >
  773.       END_QUADRIC
  774.  
  775.       TEXTURE
  776.            0.05
  777.       END_TEXTURE
  778.  
  779.       AMBIENT  0.3
  780.       DIFFUSE   0.7
  781.       REFLECTION  0.3
  782.       REFRACTION  0.3
  783.       IOR 1.05
  784.       COLOUR RED 1.0 GREEN 1.0 BLUE 1.0 ALPHA 0.5
  785.      END_OBJECT
  786.  
  787.      The following keywords may be used when defining objects:
  788.  
  789.      AMBIENT value
  790.      -      Ambient light is light that is scattered everywhere in the room. 
  791.       An object lit only by ambient light will appear to have the same
  792.       brightness over the entire surface.  The default value is very
  793.       little ambient light (0.3).  The value can range from 0.0 to 1.0.
  794.  
  795.      DIFFUSE value
  796.      -      Diffuse light is light coming from a light source that is scattered
  797.       in all directions.  An object lit only by diffuse light looks like
  798.       a rubber ball with a spot light shining on it.  The value can range
  799.       from 0.0 to 1.0.  By default, there is mostly diffuse lighting
  800.       (0.7).
  801.  
  802.      BRILLIANCE value
  803.      -      Objects can be made to appear more metallic by increasing their
  804.       brilliance.  This controls the tightness of the basic diffuse
  805.       illumination on objects and minorly adjusts the appearance of
  806.       surface shininess.  The default value is 1.0.  Higher values from
  807.       3.0 to about 10.0 can give objects a somewhat more shiny or
  808.       metallic appearance.    This is best used in concert with either
  809.       SPECULAR or PHONG highlighting.
  810.  
  811.      REFLECTION value
  812.      -      By setting the reflection value to be non-zero, you can give the
  813.       object a mirrored finish.  It will reflect all other objects in the
  814.       room.  The value can range from 0.0 to 1.0.  By default there is no
  815.       reflection.
  816.  
  817.  
  818.  
  819.  
  820.  
  821.      REFRACTION value
  822.      -      By setting the refraction value to be non-zero, the object is made
  823.       transparent.    Light will be refracted through the object like a
  824.       lens.  The value can be set between 0.0 and 1.0.  There is no
  825.       refraction by default.
  826.      IOR value
  827.      -      If the object is refracting light, then the IOR or Index of
  828.       Refraction should be set.  This determines how dense the object is.
  829.       A value of 1.0 will give no refraction.  The Index of Refraction
  830.       for Air is 1.0, Water is 1.33, glass is 1.5, and diamond is 2.4.
  831.  
  832.      PHONG value
  833.      -      Controls the amount of Phong Specular Reflection highlighting on
  834.       the object.  Causes bright shiny spots on the object, the colour of
  835.       the light source that is being reflected.  The size of the spot is
  836.       defined by the value given for PHONGSIZE below.  PHONG's value is
  837.       typically from 0.0 to 1.0, where 1.0 causes complete saturation of
  838.       the object's colour to the light source's colour at the brightest
  839.       area (center) of the highlight.  There is no PHONG highlighting
  840.       given by default.
  841.  
  842.      PHONGSIZE value
  843.      -      Controls the size of the PHONG Highlight on the object, sort of an
  844.       arbitrary "glossiness" factor.  Values range from 1.0 (Very Dull)
  845.       to 100 (Highly Polished).  Default PHONGSIZE is 40 (plastic?) if
  846.       not specified.  This is simulating the fact that slightly reflect-
  847.       ive objects, especially metallic ones, have microscopic facets,
  848.       some of which are facing in the mirror direction.  The more that
  849.       are facing that way, the shinier the object appears, and the
  850.       tighter the specular highlights become.  Phong measures the average
  851.       of facets facing in the mirror direction from the light sources to
  852.       the viewer.
  853.  
  854.      SPECULAR value
  855.      -      Very similar to PHONG Specular Highlighting, but a better model is 
  856.       used for determining light ray/object intersection, so a more
  857.       credible spreading of the highlights occur near the object
  858.       horizons, supposedly.  PHONG is thus included for mostly academic
  859.       reasons, but try them both and you decide which you like better.
  860.       This effect is most obvious for light sources behind objects.  The
  861.       size of the spot is defined by the value given for ROUGHNESS below. 
  862.       Like PHONG, SPECULAR values are typically from 0.0 to 1.0 for full
  863.       saturation.  Default is no SPECULAR highlighting.
  864.  
  865.      ROUGHNESS value
  866.      -      Controls the size of the SPECULAR Highlight on the object, relative
  867.       to the object's "roughness".  Values range from 1.0 (Very Rough) to
  868.       0.001 (Very Smooth).    The default value if not specified is 0.05
  869.       (Plastic?).  The roughness or average directional distribution of
  870.       the microfacets is facing in the same direction as the perpen-
  871.       dicular surface "normal" cause the most notable reflection of the
  872.       highlight to the observer.
  873.  
  874.      COLOUR value
  875.      -      The colour of an object can be set by using this option.  The value
  876.       is a colour or a colour constant.  For example:
  877.  
  878.      COLOUR RED 1.0  BLUE 0.4
  879.  
  880.       - or -
  881.  
  882.      DECLARE Yellow = COLOUR RED 1.0 GREEN 1.0
  883.       ...
  884.      COLOUR Yellow
  885.  
  886.  
  887.      TRANSLATE vector
  888.      ROTATE vector
  889.      SCALE vector
  890.      -      Objects can be translated, rotated, and scaled just like surfaces.
  891.       This feature is included for consistency.
  892.  
  893.      LIGHT_SOURCE
  894.      -      If the LIGHT_SOURCE keyword is used in the definition of an object,
  895.       then the object is included in the list of light sources.  It can
  896.       light objects and produce shadows.  (You should also specify the
  897.       COLOUR of the light source).    Light sources have a peculiar re-
  898.       striction:  The light source MUST be TRANSLATED to it's final
  899.       position in the scene, so the normal way to define a light source
  900.       is a sphere or quadric centered about the origin, then TRANSLATED
  901.       to where desired in the final scene.    For example:
  902.  
  903.      OBJECT
  904.       SPHERE <0.0  0.0  0.0> 2.0 END_SPHERE   {could be a quadric, too.}
  905.       TRANSLATE <100.0  120.0  40.0>
  906.  
  907.       LIGHT_SOURCE
  908.       COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
  909.       AMBIENT 1.0
  910.       DIFFUSE 0.0
  911.      END_OBJECT
  912.  
  913.  
  914.      TEXTURE
  915.      -      The texture feature is an experiment into functionally based
  916.       modelling.  This feature allows you to assign more interesting
  917.       colouring schemes to objects.  Many procedural surface textures are
  918.       provided, and by using different colour maps with them, nearly
  919.       infinite permutations are possible.  For example, you can make some
  920.       object look like wood or marble, etc.
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.      The basic TEXTURE syntax is as follows:
  928.  
  929.      TEXTURE
  930.       0.05
  931.       WOOD
  932.       TURBULENCE 0.2
  933.       TRANSLATE < 1.0 2.0 3.0 >
  934.       ROTATE < 0.0 10.0 40.0 >
  935.       SCALE < 10.0 10.0 10.0 >
  936.      END_TEXTURE
  937.  
  938.      The transformations are optional.    They allow you to transform the
  939.      texture independent of the object itself.    If you are doing animation,
  940.      then the transformations should be the same as the object
  941.      transformations so that  the texture follows the object.
  942.  
  943.      The floating-point value given immediately following the texture keyword
  944.      is an optional "texture randomness" value, which causes a minor random
  945.      scattering of calculated colour values and produces a sort of "dithered" 
  946.      appearance.
  947.  
  948.      Instead of using WOOD, you may use MARBLE, BOZO, CHECKER, or a handful
  949.      of other interesting textures.  The WOOD and MARBLE textures are
  950.      perturbed by a turbulence function.  This makes them look more random
  951.      and irregular than they would normally appear.  The amount of turbulence
  952.      can be changed by the TURBULENCE keyword followed by a number.  Values
  953.      from 0.1 to 0.3 seem to give the best results.  The default is 0.0, or
  954.      no turbulence.
  955.  
  956.      Note some of the textures given are coloration textures, such as MARBLE,
  957.      WOOD CHECKER, GRANITE, and AGATE.    These work with colour maps, and have
  958.      default "colour maps" they resort to if none are given.  The rest of the
  959.      textures available are "surface perturbation" textures, and do not dir-
  960.      ectly affect the colour of the object, but rather the surface's apparent
  961.      orientation in space. Examples of this are WAVES, RIPPLES, DENTS, BUMPS,
  962.      and WRINKLES.  Note that any given texture may include up to two actual
  963.      textures, one coloration and one surface perturbation choice per
  964.      texture.  This would allow rippled wood, or dented granite combinations, 
  965.      etc., but keep in mind that any transformations applied to one texture
  966.      (i.e. TRANSLATE or SCALE) will also transform the other one in the same
  967.      fashion.
  968.  
  969.  
  970.      The following textures are available:
  971.  
  972.      CHECKER texturing gives a checker-board appearance.  This option works
  973.      best on planes.  When using the CHECKER texturing, you must specify two
  974.      colours immediately following the word CHECKER.  These colours are the
  975.      colours of alternate squares in the checker pattern.  The default
  976.      orientation of the CHECKER texture is on an X-Z plane (good for ground
  977.      work, etc.) but to use it on an object which has mostly X-Y orientation
  978.      (such as a sphere, for instance), you must ROTATE the texture.
  979.  
  980.      To rotate the CHECKER texture onto an X-Y plane:
  981.  
  982.      TEXTURE
  983.       CHECKER COLOUR White COLOUR Red
  984.       SCALE <10.0 10.0 10.0>
  985.       ROTATE <-90.0 0.0 0.0>   { Checkers now in the X-Y plane... }
  986.      END_TEXTURE
  987.  
  988.      As mentioned above, for coloration textures such as WOOD, MARBLE, and
  989.      BOZO, etc., you may change the colouring scheme by using a colour map.
  990.      This map allows you to convert numbers from 0.0 to 1.0 (which are
  991.      generated by the ray tracer) into ranges of colours. For example, the
  992.      default BOZO colouring can be specified by:
  993.  
  994.      TEXTURE
  995.       BOZO
  996.       COLOUR_MAP
  997.            [0.0 0.4 COLOUR White COLOUR White]
  998.            [0.4 0.6 COLOUR Green COLOUR Green]
  999.            [0.6 0.8 COLOUR Blue COLOUR Blue]
  1000.            [0.8 1.0 COLOUR Red COLOUR Red]
  1001.       END_COLOUR_MAP
  1002.      END_TEXTURE
  1003.  
  1004.      BOZO texture basically takes a noise function and maps it onto the
  1005.      surface of an object.  This "noise" is defined for every point in space.
  1006.      If two points are close together, they will have noise values that are
  1007.      close together.  If they are far apart, their noise values will be
  1008.      fairly random relative to each other.
  1009.  
  1010.      The easiest way to see how it works is to try it.    With a good choice of
  1011.      colours it produces some of the most realistic looking cloudscapes you
  1012.      have ever seen.  Try a cloud color map such as:
  1013.  
  1014.      TEXTURE
  1015.       BOZO
  1016.       TURBULENCE 1.0      { A blustery day.  For a calmer one, try 0.2 }
  1017.       COLOUR_MAP
  1018.            [0.0 0.5  COLOUR RED 0.5 GREEN 0.5 BLUE 1.0  {blue to blue}
  1019.             COLOUR RED 0.5 GREEN 0.5 BLUE 1.0]
  1020.            [0.5 0.6  COLOUR RED 0.5 GREEN 0.5 BLUE 1.0  {blue to white}
  1021.             COLOUR RED 1.0 GREEN 1.0 BLUE 1.0]
  1022.            [0.6 1.001 COLOUR RED 1.0 GREEN 1.0 BLUE 1.0 {white to grey}
  1023.             COLOUR RED 0.5 GREEN 0.5 BLUE 0.5]
  1024.       END_COLOUR_MAP
  1025.       SCALE <800.0 800.0 800.0>
  1026.       TRANSLATE <200.0 400.0 100.0>
  1027.      END_TEXTURE
  1028.  
  1029.      (Check out sunset.dat for a really neat (but slow) sky pattern)
  1030.  
  1031.  
  1032.  
  1033.      The color map above indicates that for small values of texture, use a
  1034.      sky blue color solidly until about halfway turbulent, then fade through
  1035.      to white on a fairly narrow range.  As the white clouds get more turb-
  1036.      ulent and solid towards the center, pull the color map toward grey to
  1037.      give them the appearance of holding water vapor (like typical clouds).
  1038.      SPOTTED - Spotted texture is a sort of swirled random spotting of the
  1039.      colour of the object.  If you've ever seen a metal organ pipe you know
  1040.      about what it looks like (a galvanized garbage can is close...)  Play
  1041.      with this one, it might render a decent cloudscape during a very stormy 
  1042.      day (?).  No extra keywords are required.    Should work with colour maps.
  1043.      With small scaling values, looks like masonry or concrete.
  1044.  
  1045.      AGATE - this texture is similar to Marble, but uses a different turb-
  1046.      ulence function.  The TURBULENCE keyword has no effect, and as such it
  1047.      is always very turbulent.
  1048.  
  1049.      GRADIENT - this is a specialized texture that uses approximate local
  1050.      coordinates of an object to control colour map gradients.    This texture
  1051.      ONLY works with colour maps (one MUST be given!) and has a special <X,
  1052.      Y, Z> triple given after the GRADIENT keyword, which specifies any (or
  1053.      all) axes to perform the gradient action on.  (Example: a Y gradient
  1054.      <0.0, 1.0, 0.0> will give an "altitude colour map", along the Y axis).
  1055.      Values other than 0.0 are taken as 1.0 and others are meaningless.  For
  1056.      smooth repeating gradients, you should use a nearly "circular" colour
  1057.      map, that is, one in which the first colour value (0.0) is the same as
  1058.      the last one (1.001) so it "wraps around" and will cause smooth
  1059.      repeating gradient patterns.  Scaling the texture is normally required
  1060.      to achieve the number of repeating shade cycles you want. 
  1061.      Transformation of the texture is useful to prevent a "mirroring" effect
  1062.      from either side of the central 0 axes.  Here is an example of a
  1063.      gradient texture which uses a sharp "circular" color mapped gradient
  1064.      rather than a smooth one, and uses both X and Y gradients to get a
  1065.      diagonally-oriented gradient.  It produces a dandy candy cane texture!
  1066.  
  1067.      TEXTURE
  1068.       GRADIENT < 1.0 1.0 0.0 >
  1069.       COLOUR_MAP
  1070.            [0.00 0.25  COLOUR RED 1.0 GREEN 0.0 BLUE 0.0
  1071.             COLOUR RED 1.0 GREEN 0.0 BLUE 0.0]
  1072.            [0.25 0.75  COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
  1073.             COLOUR RED 1.0 GREEN 1.0 BLUE 1.0]
  1074.            [0.75 1.001 COLOUR RED 1.0 GREEN 0.0 BLUE 0.0
  1075.             COLOUR RED 1.0 GREEN 0.0 BLUE 0.0]
  1076.       END_COLOUR_MAP
  1077.       SCALE <30.0 30.0 30.0>
  1078.       TRANSLATE <30.0 -30.0 0.0>
  1079.      END_TEXTURE
  1080.  
  1081.  
  1082.      You may also specify a TURBULENCE value with the gradient to give a    
  1083.      more irregular colour gradient.  This may help to do neat things like
  1084.      fire or coronas.
  1085.  
  1086.      GRANITE - A colouring texture.  This uses a simple 1/f fractal noise
  1087.      function to give a pretty darn good grey granite texture.    Typically
  1088.      used with small scaling values (2.0 to 5.0).  Also looks good with a
  1089.      little dithering (texture randomness).  Should work with colour maps, so
  1090.      try your hand at pink granite or alabaster!
  1091.  
  1092.      RIPPLES - As mentioned above, you may optionally specify a surface
  1093.      perturbation texture which can be used in conjunction with the above
  1094.      coloration textures.  RIPPLES is one example of a surface perturbation
  1095.      texture.  This texture makes the surface look like ripples of water. 
  1096.      The RIPPLES option requires a value to determine how deep the ripples
  1097.      are:
  1098.  
  1099.      TEXTURE
  1100.       WOOD
  1101.       RIPPLES 0.3
  1102.       TRANSLATE < 1.0 2.0 3.0 >
  1103.       ROTATE < 0.0 10.0 40.0 >
  1104.       SCALE < 10.0 10.0 10.0 >
  1105.      END_TEXTURE
  1106.  
  1107.      (In this case, the WOOD, MARBLE, or BOZO, etc. keywords are optional).
  1108.      If a different colouring is specified (WOOD, MARBLE, or BOZO), then the
  1109.      COLOUR parameter is ignored (except for light sources where it gives the
  1110.      light colour or when rendering with a low -q option).
  1111.  
  1112.      WAVES - Another option that you may want to experiment with is called
  1113.      WAVES. This works in a similar way to RIPPLES except that it makes waves
  1114.      with different frequencies.  The effect is to make waves that look more
  1115.      like deep ocean waves. (I haven't done much testing on WAVES, so I can't
  1116.      guarantee that it works very well).
  1117.  
  1118.      Both WAVES and RIPPLES respond to a texturing option called PHASE. The
  1119.      PHASE option allows you to create animations in which the water seems to
  1120.      move.  This is done by making the PHASE increment slowly between frames. 
  1121.      The range from 0.0 to 1.0 gives one complete cycle of a wave.
  1122.  
  1123.      BUMPS - Approximately the same turbulence function as SPOTTED, but uses
  1124.      the derived value to perturb the surface normal.  This gives the
  1125.      impression of a "bumpy" surface, random and irregular, sort of like an
  1126.      orange.  After the BUMPS keyword, supply a single floating point value
  1127.      for the amount of surface perturbation.  Values typically range from 0.0
  1128.      (No Bumps) to 1.0 (Extremely Bumpy).  Values beyond 1.0 may do wierd
  1129.      things.
  1130.  
  1131.      DENTS - Also a surface normal perturbing texture.    Interesting when used
  1132.      with metallic textures, it gives impressions into the metal surface that
  1133.      look like dents.  A single value is supplied after the DENTS keyword to
  1134.      indicate the amount of denting required.  Values range from 0.0 (No
  1135.      Dents) to 1.0 (Fairly Dented).  Use larger values at your own risk...
  1136.      Scale the texture to make the pitting more or less frequent.
  1137.  
  1138.  
  1139.      WRINKLES mapped file in RAW format (the format output by the ray-
  1140.      tracer), IFF format or Compuserve GIF format and map that bitmap onto an
  1141.      object.  In the texture of an object, you must give the IMAGEMAP key-
  1142.      word, the format, and a file name.  The syntax is:      
  1143.  
  1144.       IMAGEMAP [gradient] RAW "filename [ONCE]"
  1145.      or   IMAGEMAP [gradient] IFF "filename [ONCE]"
  1146.      or   IMAGEMAP [gradient] GIF "filename [ONCE]"
  1147.  
  1148.      The texture will then be mapped onto the object as a repeating pattern.
  1149.      The ONCE keyword places only one image onto the object instead of an
  1150.      infinitely repeating tiled pattern.  When ONCE is used, the object's
  1151.      default colour is used as the colour outside of the image.
  1152.  
  1153.  
  1154.      By default, the image is mapped onto the XY plane in the range (0.0,
  1155.      0.0) to (1.0, 1.0).  If you would like to change this default, you may
  1156.      use an optional gradient <x, y, z> vector after the word IMAGEMAP.  This
  1157.      vector indicates which axes are to be used as the u and v (local surface
  1158.      X-Y) axes. The vector should contain one positive number and one
  1159.      negative number to indicate the u and v axes, respectively.  You may
  1160.      translate, rotate, and scale the texture to map it onto the object's
  1161.      surface as desired.  Here is an example:
  1162.  
  1163.      INCLUDE "BasicShapes.data"
  1164.  
  1165.      OBJECT
  1166.       QUADRIC Plane_XY END_QUADRIC
  1167.       TRANSLATE <0.0  -20.0  0.0>
  1168.  
  1169.       TEXTURE
  1170.            { make this texture use the x and z axes for the mapping. }
  1171.            IMAGEMAP <1.0  0.0  -1.0> GIF "image.gif"
  1172.            SCALE <40.0 40.0 40.0>
  1173.       END_TEXTURE
  1174.      END_OBJECT
  1175.  
  1176.      When I was bored with nothing to do, I decided that it would be neat to
  1177.      have turbulent texture maps.  So, I said - "what the hell!"  You can
  1178.      specify TURBULENCE with texture maps and it will perturb the image.  It
  1179.      may give some bizarre results.  Is this useful?  I dunno.    It was easy
  1180.      to do so I did it.  Try it out and see what you get.
  1181.  
  1182. Section 2.9 - Composite Objects
  1183.  
  1184.      Often it's useful to combine several objects together to act as a whole.
  1185.      A car, for example, consists of wheels, doors, a roof, etc.  A composite
  1186.      object allows you to combine all of these pieces into one object.    This
  1187.      has two advantages.  It makes it easier to move the object as a whole
  1188.      and it allows you to speed up the ray tracing by defining bounding
  1189.      shapes that contain the objects.  (Rays are first tested to see if they
  1190.      intersect the bounding shape.  If not, the entire composite object is
  1191.      ignored).    Composite objects are defined as follows:
  1192.  
  1193.      COMPOSITE
  1194.       OBJECT
  1195.            ...
  1196.       END_OBJECT
  1197.  
  1198.       OBJECT
  1199.            ...
  1200.       END_OBJECT
  1201.       ...
  1202.  
  1203.       SCALE < 2.0 2.0 2.0 >
  1204.       ROTATE < 30.0 45.0 160.0 >
  1205.       TRANSLATE < 100.0 20.0 40.0 >
  1206.      END_COMPOSITE
  1207.  
  1208.      Composite objects can contain other composite objects as well as regular
  1209.      objects.  Composite objects cannot be light sources (although any number
  1210.      of their components can).    This is because it is nearly impossible to
  1211.      determine the true "center" of the composite object, and our light
  1212.      sources are pinpoint ray sources from the center of the light source
  1213.      object, wherever that may be.
  1214.  
  1215.  
  1216. Section 2.95 - Bounding Shapes
  1217.  
  1218.      Let's face it.  This program is no speed demon.  You can save yourself
  1219.      a lot of time, however, if you use bounding shapes around any complex
  1220.      objects.  Bounding shapes tell the ray tracer that the object is totally
  1221.      enclosed by a simple shape.  When tracing rays, the ray is first tested
  1222.      against the simple bounding shape.  If it strikes the bounding shape,
  1223.      then the ray is further tested against the more complicated object
  1224.      inside.
  1225.  
  1226.      To use bounding shapes, you simply include the following lines into the
  1227.      declaration of your OBJECT or COMPOSITE_OBJECT:
  1228.  
  1229.      BOUNDED_BY
  1230.       a shape
  1231.      END_BOUND
  1232.  
  1233.  
  1234.  
  1235.      An example of a Bounding Shape:
  1236.  
  1237.      OBJECT
  1238.       INTERSECTION
  1239.            SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE
  1240.            PLANE <0.0 1.0 0.0> 0.0 END_PLANE
  1241.            PLANE <1.0 0.0 0.0> 0.0 END_PLANE
  1242.       END_INTERSECTION
  1243.  
  1244.       BOUNDED_BY
  1245.            SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE
  1246.       END_BOUND
  1247.      END_OBJECT
  1248.  
  1249.      The best bounding shape is a SPHERE since this shape is highly
  1250.      optimized.  Any shape may be used, however.
  1251.  
  1252. Section 3 - Showing the final pictures
  1253.  
  1254.      When the ray tracer draws the picture on the screen, it does not make
  1255.      good choices for the colour registers.  Without knowing all the needed
  1256.      colours ahead of time, only approximate guesses can be made.  A post-
  1257.      processor is really needed to view the final image correctly.  A post-
  1258.      processor has been provided for the Amiga which scans the picture and
  1259.      chooses the best possible colour registers.  It then redisplays the
  1260.      picture.  For the Amiga, "DumpToIFF" can optionally save this picture in
  1261.      IFF format.  The syntax for the DumpToIFF post-processor is:
  1262.  
  1263.      DumpToIFF filename
  1264.  
  1265.      where the filename is the one given in the -o parameter of the ray
  1266.      tracer.  If you didn't specify the -o option, then use:
  1267.  
  1268.      DumpToIFF data.dis
  1269.  
  1270.      If you want to save to an IFF file, then put the name of the IFF file
  1271.      after the name of the data file:
  1272.  
  1273.      DumpToIFF data.dis picture
  1274.  
  1275.      This will create a file called "picture" which contains the IFF image.
  1276.  
  1277.      For the IBM, you will probably want to use the -t option and write the
  1278.      image out in TARGA 24 format.  If you have a TARGA or compatible display
  1279.      adapter, you may view the picture in the full 16 million colors (that's
  1280.      why they still cost the big $$ bucks).  If you don't, there are several
  1281.      post-processing programs available to convert the TARGA true-color image
  1282.      into a more suitable color-mapped image (such as .GIF).  If you have a
  1283.      VGA or MCGA adapter capable of 320x200 by 256 colors, then you may use
  1284.      the -d option which will display the image as it generates using only
  1285.      approximate screen colors.  No hardware test is performed, so if you
  1286.      don't have a VGA or MCGA, -> DON'T <- use the -d option!
  1287.  
  1288.      When displaying the image to screen, a HSV conversion method is used
  1289.      (hue, saturation, value).    This is a convenient way of translating
  1290.      colors from a "true color" format (16 million) down a "colour mapped"
  1291.      format of something reasonable (like 256), while still approximating the
  1292.      color as closely as the available display hardware permits.  As
  1293.      mentioned previously, the tracer has no way of knowing which colors will
  1294.      be finally used in the image, nor can it deal properly with all of the
  1295.      colors which will be generated (up to 16M), so only 4 shades each of 64
  1296.      possible hues are mapped into the palette DAC, as well as black, white,
  1297.      and two grey levels. The advantage a post-processor has in choosing
  1298.      mapped colors is that it can throw away all the unused colors in the
  1299.      palette map, and thereby free up some space for making better gradient
  1300.      shades of the colors that are actually used.
  1301.  
  1302.      There are several available image processing programs that can do this,
  1303.      a public domain one that is very good is PICLAB, by the Stone Soup Group 
  1304.      (the folks who brought you FRACTINT).  The procedure is to load the
  1305.      TARGA file, then use the MAKEPAL command to generate a 256 color map
  1306.      which is the histogram-weighted average of the most-used colors in the
  1307.      image (You could also PLOAD a palette file from FRACTINT or one you
  1308.      previously had saved using PSAVE).  You then MAP the palette onto the
  1309.      image one of two ways:
  1310.  
  1311.      1)   If the DITHER variable is OFF, a nearest-match-color-fit is used,
  1312.       which can sometimes produce unwanted "banding" of colored regions
  1313.       (called false contours).
  1314.      2)   If the DITHER variable is ON, then a standard dither is used to
  1315.       determine final color values.  This is much better at blending the
  1316.       color bands, but can produce noise in reflections and make mirrors
  1317.       appear dirty or imperfect.
  1318.  
  1319.      Then you would typically SHOW the image or GSAVE it into GIF format. 
  1320.      While the picture is still in the unmapped form (TARGA, etc.) you can
  1321.      perform a variety of advanced image processing transformations and
  1322.      conversions, so save the .TGA or .RAW files you make (in case you ever
  1323.      get a TARGA card, or give them to a friend who has one!).
  1324.  
  1325.      A commercial product that also does a good job of nearest-match-color-
  1326.      fit is the CONVERT utility of The AutoDesk Animator.  However, the
  1327.      dither effect is not as good as that of PICLAB.  To convert the file in
  1328.      AA's CONVERT, you LOAD TARGA, then in the CONVERT menu, go to the SCALE
  1329.      function and just hit RENDER.  Click on the DITHER (lights up with an
  1330.      asterisk when on) if you want it to use it's dithering.  CONVERT will
  1331.      scale (if asked to) and then do a histogram of total used colors like
  1332.      PICLAB, but then makes 7 passes on the color map and image to determine
  1333.      shading thresholds of each hue.  This nearly eliminates the color
  1334.      banding (false contours) without resorting to dithering.  By now you
  1335.      must get the feeling DITHER is a 4-letter word.  If you have a low-
  1336.      resolution display, it is.  If you have too few colors, however, it can
  1337.      be a saving grace.  At resolutions of 640x400 or higher the "spray
  1338.      paint" effect of dithering and anti-aliasing is much less noticeable,
  1339.      and effects a much smoother blending appearance.
  1340.  
  1341. Section 4 - Handy Hints/Quick Start
  1342.  
  1343.      -      To see a quick version of your picture, use -w64 -h80 as command
  1344.       line parameters on the Amiga.  For the IBM, try -w80 -h50.  This
  1345.       displays the picture in a small rectangle so that you can see how
  1346.       it will look.
  1347.  
  1348.      -      Try using the sample default files for different usages - QUICK.DEF
  1349.       shows a fast postage-stamp rendering (80x50, as above) to the
  1350.       screen only, LOCKED.DEF will display the picture with anti-aliasing
  1351.       on (takes forever) with no abort (do this before you go to bed...).
  1352.       The normal default options file TRACE.DEF is read and you can
  1353.       supersede this with another .DEF file by specifying it on the
  1354.       command line, for example:
  1355.  
  1356.       trace -iworld.dat -oworld.out quick.def
  1357.  
  1358.      -      When translating light sources, translate the OBJECT, not the
  1359.       QUADRIC surface.  The light source uses the center of the object as
  1360.       the origin of the light.
  1361.  
  1362.      -      When animating objects with solid textures, the textures must move
  1363.       with the object, i.e. apply the same ROTATE or TRANSLATE functions
  1364.       to the texture as to the object itself.
  1365.  
  1366.      -      You can declare constants for most of the data types in the program
  1367.       including floats and vectors.  By combining this with INCLUDE
  1368.       files, you can easily separate the parameters for an animation into
  1369.       a separate file.
  1370.  
  1371.      -      The amount of ambient light plus diffuse light should be less than
  1372.       or equal to 1.0.  The program accepts any value, but may produce
  1373.       strange results.
  1374.  
  1375.      -      When using ripples, don't make the ripples too deep or you may get
  1376.       strange results (the dreaded "digital zits"!).
  1377.  
  1378.      -      Wood textures usually look better when they are scaled to different
  1379.       values in x, y, and z, and rotated to a different angle.
  1380.  
  1381.      -      You can sort of dither a colour by placing a floating point number
  1382.       into the texture record:
  1383.  
  1384.       TEXTURE
  1385.            0.05
  1386.       END_TEXTURE
  1387.  
  1388.       This adds a small random value to the intensity of the diffuse
  1389.       light on the object.    Don't make the number too big or you may get
  1390.       strange results.
  1391.  
  1392.       Better results can be obtained, however, by doing the dithering in
  1393.       a post-processor.
  1394.  
  1395.  
  1396.      -      You can compensate for non-square aspect ratios on the monitors by
  1397.       making the RIGHT vector in the VIEWPOINT longer or shorter.  A good
  1398.       value for the Amiga is about 1.333.  This seems ok for IBM's too at
  1399.       320x200 resolution.  If your spheres and circles aren't round, try
  1400.       varying it.
  1401.  
  1402.      -      If you are importing images from other systems, you may find that
  1403.       the shapes are backwards (left-to-right inverted) and no rotation
  1404.       can make them right.    All you have to do is negate the terms in the
  1405.       RIGHT vector of the viewpoint to flip the camera left-to-right.
  1406.  
  1407.      -      By making the DIRECTION vector in the VIEWPOINT longer, you can
  1408.       achieve the effect of a zoom lens.
  1409.  
  1410.      -      When rendering on the Amiga, use a resolution of 319 by 400 to
  1411.       create a full sized HAM picture.
  1412.  
  1413.  
  1414. Section 5 - Known Bugs
  1415.      There is a bug in the code to use Vector constants.  The fix involves
  1416.      re-working the parser quite a bit and I don't want to do that now.
  1417.  
  1418.  
  1419. Section 6 - Concluding remarks
  1420.  
  1421.      I'm sure that there are bugs in the code somewhere, but I've done my
  1422.      best to remove all the bugs I could find.    I also think that the object
  1423.      description language needs to be re-worked.  Its current syntax is a bit 
  1424.      cumbersome.  The system could also use a good graphical interface    :-).
  1425.  
  1426.      To that end, a conversion utility is supplied which will take in a
  1427.      Sculpt-Animate 4-D object and map it into DKB's primitive TRIANGLES. 
  1428.      For the IBM, we have heard, but cannot confirm, there is a utility
  1429.      around which will convert AUTOCAD .DXF files into Sculpt-4D files.  If
  1430.      anybody has it or any info about it, please contact either David Buck or
  1431.      Aaron Collins.
  1432.  
  1433.      The IBM version is also supplied with two stand-alone TARGA-24 utilities
  1434.      which were written by Aaron A. Collins.  These are HALFTGA, which will
  1435.      chop a TARGA-24 file in half in both X and Y dimensions for low-
  1436.      resolution systems, and another file called GLUETGA which will paste
  1437.      together several TARGA-24 files (of any resolution) into one.  This is
  1438.      principally for concatenating together several partial (interrupted)
  1439.      trace output files into one.
  1440.  
  1441.      I would like to thank Rick Mallett from Carleton University for his help
  1442.      in testing this program, for his comments and suggestions, and for
  1443.      creating the data file for ROMAN.DATA - awesome!
  1444.  
  1445.      I would also like to thank my beta testers for all the help, bug reports,
  1446.      suggestions, comments, and time spent.  This version of the ray tracer
  1447.      wouldn't have been possible without them.  Thanks guys.
  1448.  
  1449. Enjoy,
  1450. David Buck
  1451.  
  1452.